package com.alex.webnote.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alex.common.Constants;
import com.alex.common.ILogger;
import com.alex.common.service.CounterService;
import com.alex.common.worker.IWorker;
import com.alex.webnote.dao.WebNoteDao;

@Deprecated
@Controller
@RequestMapping("/hotsworker")
public class HotsWorker implements IWorker {
	@Autowired
	private CounterService counterService;

	@Autowired
	private WebNoteDao webNoteDao;

	@Override
	public boolean isChecked(String checker) {
		return Constants.APP_NAME_WEBNOTE_HOTS.equals(checker);
	}

	/**
	 * /hotsworker?checker=webnotehots
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(method = { RequestMethod.GET })
	public @ResponseBody
	String index(HttpServletRequest request, HttpServletResponse response) {
		if (isChecked(request.getParameter("checker"))) {
			int sum = 0;
			// counterService.saveCounter(webNoteDao,
			// Constants.APP_NAME_WEBNOTE_HOTS);
			String msg = "hotsworker execute OK, save " + sum;
			ILogger.logger_common.warn(msg);
			return msg;
		} else {
			return "false";
		}
	}

}
